﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;

namespace DemoTest
{
    public partial class Form1 : Form
    {

        [DllImport(@"C:\Program Files (x86)\税控盘组件接口(V2.6.0.1)\NISEC_SKPC.dll", EntryPoint = "OperateDisk")]

        public extern static void OperateDisk(StringBuilder sInputInfo, StringBuilder sOutInfo);

        public static string skpbh = "499000121625";
        public static string skpkl = "88888888";
        public static string keypwd = "111111";
        public static string xhdwsbh = "500102010002143";
        public static string xhdwmc = "升级版测试用户2257";
        public static string xhdwdzdh = "重庆市北部新区清枫北路10号双子A座02365584558";
        public static string xhdwyhzh = "中国银行重庆分行九龙坡支行111111111";
        public static string kpr = "曾晓明";
        public static string kpjh = "0000";
        public static string qmcs = "0000004282000000";

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        #region 税控盘查询
        public void SKPCX()
        {
            string str = this.textBox1.Text.ToString();
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='税控盘信息查询' id='SKPXXCX'>
                            <body yylxdm='1'>
                            <output>
                            <skpbh></skpbh>
                            <nsrsbh></nsrsbh>
                            <nsrmc></nsrmc>
                            <swjgdm></swjgdm>
                            <swjgmc></swjgmc>
                            <fplxdm></fplxdm>
                            <dqsz></dqsz>
                            <qysj></qysj>
                            <bbh></bbh>
                            <kpjh></kpjh>
                            <qylx></qylx>
                            <blxx></blxx>
                            <qtkzxx></qtkzxx>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            this.textBox2.Text  = sb1.ToString();
        }
        #endregion

        #region 发票打印

        public void FPDY()
        {
            //            string str1 = @"<?xml version='1.0' encoding='gbk'?>
            //                            <business comment='发票打印' id='FPDY'>
            //                              <body yylxdm='1'>
            //                                <input>
            //                                  <nsrsbh>500102010000394</nsrsbh>
            //                                  <skpbh>499000107284</skpbh>
            //                                  <skpkl>88888888</skpkl>
            //                                  <keypwd>111111</keypwd>
            //                                  <fplxdm>007</fplxdm>
            //                                  <fpdm>1110098080</fpdm>
            //                                  <fphm>87650330</fphm>
            //                                  <dylx>0</dylx>
            //                                  <dyfs>1</dyfs>
            //                                </input>
            //                              </body>
            //                            </business>";

            //            <fpdm>1110098080</fpdm>
            //<fphm>87650349</fphm>
            string str = this.textBox1.Text;


            string strxml = @"<?xml version='1.0' encoding='gbk'?>
                <business comment='发票打印' id='FPDY'>
                <body yylxdm='1'><input><nsrsbh>500102010002166</nsrsbh>
                <skpbh>499000121852</skpbh>
                <skpkl>88888888</skpkl>
                <keypwd>111111</keypwd>
                <fplxdm>007</fplxdm>
                <fpdm>150000000256</fpdm>
                <fphm>34210007</fphm>
                <dylx>0</dylx>
                <dyfs>1</dyfs>
                </input>
                </body></business>";


            string str2 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票打印' id='FPDY'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <dyfs></dyfs>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str2);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 注册码导入


        public string read(string path)
        {
            string str = "";
            try
            {
                StreamReader sr = new StreamReader(path, Encoding.Default);
                String line;

                while ((line = sr.ReadLine()) != null)
                {
                    str += line;
                    //Console.WriteLine(line.ToString());
                }

            }
            catch (IOException e)
            {
                MessageBox.Show(e.ToString());
            }
            return str;
        }

        public void ZCMDR()
        {
            string str = this.textBox1.Text;
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='注册码信息导入' id='ZCMDR'>
                            <body yylxdm='1'>
                            <output>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            this.textBox2.Text  = sb1.ToString();
        }

        #endregion

        #region 发票开具

        public void FPKJ()
        {

            string str = this.textBox1.Text;
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <kprq></kprq>
                            <hjje></hjje>
                            <skm></skm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            this.textBox2.Text = sb1.ToString();
        }

        #endregion

        #region 收购发票

        public void SGFP()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                        <business comment='发票开具' id='FPKJ'>
                          <body yylxdm='1'>
                            <input>
                              <skpbh>499000107284</skpbh>
                              <skpkl>88888888</skpkl>
                              <keypwd>111111</keypwd>
                              <fplxdm>007</fplxdm>
                              <kplx>0</kplx>
                              <tspz>00</tspz>
                              <xhdwsbh>500102010000394</xhdwsbh>
                              <xhdwmc>升级版测试用户394</xhdwmc>
                              <xhdwdzdh>双子座a栋3楼</xhdwdzdh>
                              <xhdwyhzh>65584558</xhdwyhzh>
                              <ghdwsbh></ghdwsbh>
                              <ghdwmc>zhangsan</ghdwmc>
                              <ghdwdzdh></ghdwdzdh>
                              <ghdwyhzh></ghdwyhzh>
                              <fyxm count='1'>
                                <group xh='1'>
                                  <fphxz>0</fphxz>
                                  <spmc>大米</spmc>
                                  <spsm></spsm>
                                  <ggxh></ggxh>
                                  <dw>方</dw>
                                  <spsl>1</spsl>
                                  <dj>5000.00</dj>
                                  <je>5000.00</je>
                                  <sl>0.00</sl>
                                  <se>0.00</se>
                                  <hsbz>0</hsbz>
                                </group>
                              </fyxm>
                              <zhsl></zhsl>
                              <hjje>5000.00</hjje>
                              <hjse>0.00</hjse>
                              <jshj>5000.00</jshj>
                              <bz></bz>
                              <skr>超级系统管理员</skr>
                              <fhr>超级系统管理员</fhr>
                              <kpr>超级系统管理员</kpr>
                              <jmbbh></jmbbh>
                              <zyspmc></zyspmc>
                              <spsm></spsm>
                              <qdbz>0</qdbz>
                              <ssyf></ssyf>
                              <kpjh>0000</kpjh>
                              <tzdbh></tzdbh>
                              <yfpdm></yfpdm>
                              <yfphm></yfphm>
                              <qmcs>0000004282000000</qmcs>
                            </input>
                          </body>
                        </business>";

            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <kprq></kprq>
                            <hjje></hjje>
                            <skm></skm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }

        #endregion

        #region 红冲发票

        public void HCFP()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                        <business comment='发票开具' id='FPKJ'>
                          <body yylxdm='1'>
                            <input>
                              <skpbh>499000121625</skpbh>
                              <skpkl>88888888</skpkl>
                              <keypwd>111111</keypwd>
                              <fplxdm>004</fplxdm>
                              <kplx>1</kplx>
                              <tspz>00</tspz>
                              <xhdwsbh>500102010002143</xhdwsbh>
                              <xhdwmc>升级版测试用户2143</xhdwmc>
                              <xhdwdzdh>1</xhdwdzdh>
                              <xhdwyhzh>1</xhdwyhzh>
                              <ghdwsbh>500102010002169</ghdwsbh>
                              <ghdwmc>购货单位名称</ghdwmc>
                              <ghdwdzdh></ghdwdzdh>
                              <ghdwyhzh></ghdwyhzh>
                              <fyxm count='1'>
                                <group xh='1'>
                                  <fphxz>0</fphxz>
                                  <spmc>大米</spmc>
                                  <spsm></spsm>
                                  <ggxh></ggxh>
                                  <dw>方</dw>
                                  <spsl>-1</spsl>
                                  <dj>-1000.00</dj>
                                  <je>-1000.00</je>
                                  <sl>0.17</sl>
                                  <se>-170.00</se>
                                  <hsbz>0</hsbz>
                                </group>
                              </fyxm>
                              <zhsl></zhsl>
                              <hjje>-1000.00</hjje>
                              <hjse>-170.00</hjse>
                              <jshj>-1170.00</jshj>
                              <bz></bz>
                              <skr>超级系统管理员</skr>
                              <fhr>超级系统管理员</fhr>
                              <kpr>超级系统管理员</kpr>
                              <jmbbh></jmbbh>
                              <zyspmc></zyspmc>
                              <spsm></spsm>
                              <qdbz>0</qdbz>
                              <ssyf></ssyf>
                              <kpjh>0000</kpjh>
                              <tzdbh>1111111111111111111</tzdbh>
                              <yfpdm>1110098079</yfpdm>
                              <yfphm>18885527</yfphm>
                              <qmcs>0000004282000000</qmcs>
                            </input>
                          </body>
                        </business>";

            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <kprq></kprq>
                            <hjje></hjje>
                            <skm></skm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion 发票开具

        #region 货运专票红冲
        /// <summary>
        /// 货运专票红冲
        /// </summary>
        public void HYZPHC()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <input>
                            <skpbh>499000121625</skpbh>
                            <skpkl>88888888</skpkl>
                            <keypwd>111111</keypwd>
                            <fplxdm>009</fplxdm>
                            <kplx>0</kplx>
                            <cyrsbh>500102010002143</cyrsbh>
                            <cyrmc>升级版测试用户2143</cyrmc>
                            <spfsbh>500102010002143</spfsbh>
                            <spfmc>重庆百望九赋软件服务有限公司</spfmc>
                            <shrsbh>500102010002143</shrsbh>
                            <shrmc>重庆百望九赋软件服务有限公司</shrmc>
                            <fhrsbh>500102010002143</fhrsbh>
                            <fhrmc>重庆百望九赋软件服务有限公司</fhrmc>
                            <qyd></qyd>
                            <fyxm count='1'>
                            <group xh='1'>
                            <xmmc>机动车</xmmc>
                            <bhsje>-73873.87</bhsje>
                            <hsbz>0</hsbz>
                            <sjje>-73873.87</sjje>
                            </group>
                            </fyxm>
                            <yshwxx></yshwxx>
                            <hjje>-73873.87</hjje>
                            <sl>0.11</sl>
                            <se>-8126.13</se>
                            <jshj>-82000.00</jshj>
                            <czch>-23456</czch>
                            <ccdw>1</ccdw>
                            <bz>备注</bz>
                            <skr>收款人</skr>
                            <fhr>复核人</fhr>
                            <kpr>管理员</kpr>
                            <tzdbh>1234567891234567893</tzdbh>
                            <yfpdm>1000141760</yfpdm>
                            <yfphm>19988911</yfphm>
                            <qmcs>0000004282000000</qmcs>
                            </input>
                            </body>
                            </business>";

            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <kprq></kprq>
                            <hjje></hjje>
                            <skm></skm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 机动车票红冲
        /// <summary>
        /// 机动车票红冲
        /// </summary>
        public void JDFFPHC()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                                <business comment='发票开具' id='FPKJ'>
                                <body yylxdm='1'>
                                <input>
                                <skpbh>499000121625</skpbh>
                                <skpkl>88888888</skpkl>
                                <keypwd>111111</keypwd>
                                <fplxdm>005</fplxdm>
                                <nsrsbh>500102010002143</nsrsbh>
                                <kplx>1</kplx>
                                <ghdwmc>重庆百望九赋软件服务有限公司</ghdwmc>
                                <sfzhm>500123199635236897</sfzhm>
                                <ghfsbh>500102010002143</ghfsbh>
                                <scqymc>buck</scqymc>
                                <cllx>轿车</cllx>
                                <cpxh>gl8</cpxh>
                                <cd>重庆</cd>
                                <hgzh>123456</hgzh>
                                <jkzmsh>023456</jkzmsh>
                                <sjdh>023456</sjdh>
                                <fdjhm>lons999999</fdjhm>
                                <cjhm>lons999999</cjhm>
                                <jshj>-80000.00</jshj>
                                <dh>1</dh>
                                <zh>1</zh>
                                <dz>1</dz>
                                <khyh>1</khyh>
                                <zzssl>0.17</zzssl>
                                <zzsse>-11623.93</zzsse>
                                <bhsj>-68376.07</bhsj>
                                <wspzhm></wspzhm>
                                <dw>1.5</dw>
                                <xcrs>5</xcrs>
                                <bz></bz>
                                <kpr>管理员</kpr>
                                <tzdbh>1234567899876543210</tzdbh>
                                <yfpdm>110000304050</yfpdm>
                                <yfphm>14444889</yfphm>
                                <qmcs>0000004282000000</qmcs>
                                </input>
                                </body>
                                </business>";

            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <kprq></kprq>
                            <hjje></hjje>
                            <skm></skm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 发票查询

        public void FPCX()
        {
            string str = this.textBox1.Text;
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票查询' id='FPCX'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            <fpxx count='1'>
                            <group xh='1'>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <fpzt></fpzt>
                            <scbz><scbz>
                            <kprq></kprq>
                            <kpsj></kpsj>
                            <tspz></tspz>
                            <skpbh></skpbh>
                            <skm></skm>
                            <jym></jym>
                            <xhdwsbh></xhdwsbh>
                            <xhdwmc></xhdwmc>
                            <xhdwdzdh></xhdwdzdh>
                            <xhdwyhzh></xhdwyhzh>
                            <ghdwsbh></ghdwsbh>
                            <ghdwmc></ghdwmc>
                            <ghdwdzdh></ghdwdzdh>
                            <ghdwyhzh></ghdwyhzh>
                            <fyxm count='1'>
                            <group xh='1'>
                            <fphxz></fphxz>
                            <spmc></spmc>
                            <spsm></spsm>
                            <ggxh></ggxh>
                            <dw></dw>
                            <spsl></spsl>
                            <dj></dj>
                            <je></je>
                            <sl></sl>
                            <se></se>
                            <hsbz></hsbz>
                            </group>
                            </fyxm>
                            <qdxm count='1'>
                            <group xh='1'>
                            <fphxz></fphxz>
                            <spmc></spmc>
                            <spsm></spsm>
                            <ggxh></ggxh>
                            <dw></dw>
                            <spsl></spsl>
                            <dj></dj>
                            <je></je>
                            <sl></sl>
                            <se></se>
                            <hsbz></hsbz>
                            </group>
                            </qdxm>
                            <qtxm count='1'>
                            <group xh='1'>
                            <sl></sl>
                            <je></je>
                            <se></se>
                            </group>
                            </qtxm>
                            <zhsl></zhsl>
                            <hjje></hjje>
                            <hjse></hjse>
                            <jshj></jshj>
                            <bz></bz>
                            <skr></skr>
                            <fhr></fhr>
                            <kpr></kpr>
                            <jmbbh></jmbbh>
                            <zyspmc></zyspmc>
                            <spsm></spsm>
                            <qdbz></qdbz>
                            <ssyf></ssyf>
                            <kpjh></kpjh>
                            <tzdbh></tzdbh>
                            <yfpdm></yfpdm>
                            <yfphm></yfphm>
                            <zfrq></zfrq>
                            <zfr></zfr>
                            <qmcs></qmcs>
                            <qmz></qmz>
                            <ykfsje></ykfsje>
                            </group>
                            </fpxx>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            this.textBox2.Text  = sb1.ToString();
        }
        #endregion

        #region 货运发票

        public void HYFP()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                        <business comment='发票开具' id='FPKJ'>
                        <body yylxdm='1'>
                        <input>
                        <skpbh>499000121852</skpbh>
                        <skpkl>88888888</skpkl>
                        <keypwd>111111</keypwd>
                        <fplxdm>009</fplxdm>
                        <kplx>0</kplx>
                        <cyrsbh>500102010002166</cyrsbh>
                        <cyrmc>升级版测试用户2166</cyrmc>
                        <spfsbh>500102010002167</spfsbh>
                        <spfmc>华晨鑫源</spfmc>
                        <shrsbh>500102010002168</shrsbh>
                        <shrmc>华晨鑫源产品部</shrmc>
                        <fhrsbh>500102010002169</fhrsbh>
                        <fhrmc>重庆百望</fhrmc>
                        <qyd>重庆江北、万州、涪陵</qyd>
                        <fyxm count='1'>
                        <group xh='1'>
                        <xmmc>金杯车</xmmc>
                        <bhsje>100000</bhsje>
                        <hsbz>0</hsbz>
                        <sjje>111000.00</sjje>
                        </group>
                        </fyxm>
                        <yshwxx>发的顺丰快递</yshwxx>
                        <hjje>100000.00</hjje>
                        <sl>0.11</sl>
                        <se>11000.00</se>
                        <jshj>111000.00</jshj>
                        <czch>TB/T 2435-1993</czch>
                        <ccdw>1.5</ccdw>
                        <bz>金杯</bz>
                        <skr>张三</skr>
                        <fhr>李四</fhr>
                        <kpr>管理员</kpr>
                        <tzdbh></tzdbh>
                        <yfpdm></yfpdm>
                        <yfphm></yfphm>
                        <qmcs>0000004282000000</qmcs>
                        </input>
                        </body>
                        </business>";
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <kprq></kprq>
                            <skm></skm>
                            <jym></jym>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>
                            ";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }

        #endregion

        #region 监控数据查询
        public void JKSJCX()
        {
            string str = this.textBox1.Text;
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='监控数据查询' id='JKSJCX'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <kpjzsj></kpjzsj>
                            <bsqsrq></bsqsrq>
                            <bszzrq></bszzrq>
                            <dzkpxe></dakpxe>
                            <zsljxe></zsljxe>
                            <fsljxe></fsljxe>
                            <fsfpbz></fsfpbz>
                            <fsfpts></fsfpts>
                            <zxbsrq></zxbsrq>
                            <syrl></syrl>
                            <scjzrq></scjzrq>
                            <xdgnbs></xdgnbs>
                            <lxkpsc></lxkpsc>
                            <lxkpzs></lxkpzs>
                            <lxzsljje></lxzsljje>
                            <lxfsljje></lxfsljje>
                            <lxkzxx></lxkzxx>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            this.textBox2.Text  = sb1.ToString();
        }
        #endregion

        #region 税种税目查询
        public void SZSMCX()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                        <business comment='税种税目信息查询' id='SZSMCX'>
                        <body yylxdm='1'>
                        <input>
                        <nsrsbh>纳税人识别号</nsrsbh>
                        <skpbh>税控盘编号</skpbh>
                        <skpkl>税控盘口令</skpkl>
                        <fplxdm>发票类型代码</fplxdm>
                        </input>
                        </body>
                        </business>";
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='税种税目信息查询' id='SZSMCX'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <szsmxx count='2'>
                            <group xh='1'>
                            <szsmsyh></szsmsyh>
                            <szsmdm></szsmdm>
                            <sl></sl>
                            <hsbz></hsbz>
                            <szmc></szmc>
                            <smmc></smmc>
                            </group>
                            <group xh='2'>
                            <szsmsyh></szsmsyh>
                            <szsmdm></szsmdm>
                            <sl></sl>
                            <hsbz></hsbz>
                            <szmc></szmc>
                            <smmc></smmc>
                            </group>
                            </szsmxx>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 购票信息查询
        public void GPXXCX()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='购票信息查询' id='GPXXCX'>
                            <body yylxdm='1'>
                            <input>
                            <nsrsbh>纳税人识别号</nsrsbh>
                            <skpbh>税控盘编号</skpbh>
                            <skpkl>税控盘口令</skpkl>
                            <fplxdm>发票类型代码</fplxdm>
                            </input>
                            </body>
                            </business>";
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='购票信息查询' id='GPXXCX'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fplgbw></fplgbw>
                            <dqfpdm></dqfpdm>
                            <dqfphm></dqfphm>
                            <zsyfs></zsyfs>
                            <fpdxx count='2'>
                            <group xh='1'>
                            <fpdm></fpdm>
                            <qshm></qshm>
                            <zzhm></zzhm>
                            <fpfs></fpfs>
                            <syfs></syfs>
                            <lgrq></lgrq>
                            <lgry></lgry>
                            </group>
                            <group xh='2'>
                            <fpdm></fpdm>
                            <qshm></qshm>
                            <zzhm></zzhm>
                            <fpfs></fpfs>
                            <syfs></syfs>
                            <lgrq></lgrq>
                            <lgry></lgry>
                            </group>
                            </fpdxx>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 机动车专票

        public void JDCFP()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                        <business comment='发票开具' id='FPKJ'>
                        <body yylxdm='1'>
                        <input>
                        <skpbh>499000121852</skpbh>
                        <skpkl>88888888</skpkl>
                        <keypwd>111111</keypwd>
                        <fplxdm>005</fplxdm>
                        <nsrsbh>500102010002166</nsrsbh>
                        <kplx>0</kplx>
                        <ghdwmc>重庆百望</ghdwmc >
                        <sfzhm>500226199305236895</sfzhm>
                        <ghfsbh>500102010002167</ghfsbh>
                        <scqymc>华晨鑫源</scqymc>
                        <cllx>轿车</cllx>
                        <cpxh>渝c:8k666</cpxh>
                        <cd>重庆</cd>
                        <hgzh>4578</hgzh>
                        <jkzmsh>1245</jkzmsh>
                        <sjdh>1245</sjdh>
                        <fdjhm>123456</fdjhm>
                        <cjhm>LSVAM4187C2184847</cjhm>
                        <jshj>100000.00</jshj>
                        <dh>65584558</dh>
                        <zh>帐号</zh>
                        <dz>双子座</dz>
                        <khyh>建设银行</khyh>
                        <zzssl>0.17</zzssl>
                        <zzsse>14529.91</zzsse>
                        <bhsj>85470.09</bhsj>
                        <wspzhm></wspzhm>
                        <dw>2</dw>
                        <xcrs>7</xcrs>
                        <bz>机动车发票</bz>
                        <kpr>管理员</kpr>
                        <qmcs>0000004282000000</qmcs>
                        </input>
                        </body>
                        </business>";
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <kprq></kprq>
                            <hjje></hjje>
                            <skm></skm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 发票作废

        public void FPZF()
        {

            string str = this.textBox1.Text;
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票作废' id='FPZF'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpdm></fpdm>
                            <fphm></fphm>
                            <zfrq></zfrq>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            string strxml = this.textBox1.Text.ToString();
            StringBuilder sb = new StringBuilder(strxml);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            this.textBox2.Text  = sb1.ToString();
        }
        #endregion

        #region 数据抄报

        public void SJCB()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票数据抄报' id='FPSJCB'>
                            <body yylxdm='1'>
                            <input>
                            <nsrsbh>纳税人识别号</nsrsbh>
                            <skpbh>税控盘编号</skpbh>
                            <skpkl>税控盘口令</skpkl>
                            <keypwd>数字证书密码</keypwd>
                            <svrIp>抄报地址</svrIp>
                            <svrPort>抄报端口</svrPort>
                            <fplxdm>发票类型</fplxdm>
                            </input>
                            </body>
                            </business>";
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票监控返写' id='FPJKFX'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm>发票类型</fplxdm>
                            <returncode>00000000</returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 监控回传

        public void SJCB1()
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票监控返写' id='FPJKFX'>
                            <body yylxdm='1'>
                            <input>
                            <nsrsbh>纳税人识别号</nsrsbh>
                            <skpbh>税控盘编号</skpbh>
                            <skpkl>税控盘口令</skpkl>
                            <keypwd>数字证书密码</keypwd>
                            <svrIp>下载监控回传地址</svrIp>
                            <svrPort>下载监控回传端口</svrPort>
                            <fplxdm>发票类型</fplxdm>
                            </input>
                            </body>
                            </business>";
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票监控返写' id='FPJKFX'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm>004</fplxdm>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            MessageBox.Show(sb1.ToString());
        }
        #endregion

        #region 发票实时上传

        public void FPSC()
        {
            string str = this.textBox1.Text;
            string str1 = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票上传' id='FPSC'>
                            <body yylxdm='1'>
                            <output>
                            <fplxdm></fplxdm>
                            <fpzs></fpzs>
                            <returncode></returncode>
                            <returnmsg></returnmsg>
                            </output>
                            </body>
                            </business>";
            StringBuilder sb = new StringBuilder(str);
            StringBuilder sb1 = new StringBuilder(str1);
            OperateDisk(sb, sb1);
            string strstr = sb1.ToString();
            MessageBox.Show(strstr);
        }
        #endregion

        private void btn_zcmdr_Click(object sender, EventArgs e)
        {
            ZCMDR();//注册码信息导入
        }

        private void btn_skpcx_Click(object sender, EventArgs e)
        {
            SKPCX();//税控盘信息查询
        }

        private void btn_jksjcx_Click(object sender, EventArgs e)
        {
            JKSJCX();//监控数据查询
        }

        private void btn_SGFP_Click(object sender, EventArgs e)
        {
            //SGFP();
            FPKJ();
        }

        /// <summary>
        /// 发票打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            FPDY();
        }

        private void btn_FPZF_Click(object sender, EventArgs e)
        {
            FPZF();
        }

        private void btn_FPSC_Click(object sender, EventArgs e)
        {
            FPSC();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FPCX();
        }

        private void btn_zcmdr_MouseDown(object sender, MouseEventArgs e)
        {
            string path = @"C:\Program Files (x86)\税控盘组件接口(V2.6.0.1)\500102010002143499000121625.txt";
            string zcm = read(path);
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='注册码信息导入' id='ZCMDR'>
                            <body yylxdm='1'>
                            <input>
                            <zcmxx>"+zcm+@"</zcmxx>
                            </input>
                            </body>
                            </business>";
            this.textBox1.Text = str.ToString();
        }

        private void btn_jksjcx_MouseDown(object sender, MouseEventArgs e)
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='监控数据查询' id='JKSJCX'>
                            <body yylxdm='1'>
                            <input>
                            <nsrsbh>500102010002255</nsrsbh>
                            <skpbh>499000123647</skpbh>
                            <skpkl>88888888</skpkl>
                            <keypwd>111111</keypwd>
                            <fplxdm>007</fplxdm>
                            </input>
                            </body>
                            </business>";
            this.textBox1.Text = str.ToString();
        }

        private void btn_skpcx_MouseDown(object sender, MouseEventArgs e)
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                           <business comment='税控盘信息查询' id='SKPXXCX'>
                           <body yylxdm='1'>
                           <input>
                           <skpkl>88888888</skpkl>
                           </input>
                           </body>
                           </business>";
            this.textBox1.Text = str.ToString();
        }

        private void btn_SGFP_MouseDown(object sender, MouseEventArgs e)
        {
            string strin = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                              <body yylxdm='1'>
                                <input>
                                  <skpbh>"+skpbh+@"</skpbh>
                                  <skpkl>" + skpkl + @"</skpkl>
                                  <keypwd>" + keypwd + @"</keypwd>
                                  <fplxdm>004</fplxdm>
                                  <kplx>0</kplx>
                                  <tspz>00</tspz>
                                  <xhdwsbh>" + xhdwsbh + @"</xhdwsbh>
                                  <xhdwmc>" + xhdwmc + @"</xhdwmc>
                                  <xhdwdzdh>" + xhdwdzdh + @"</xhdwdzdh>
                                  <xhdwyhzh>" + xhdwyhzh + @"</xhdwyhzh>
                                  <ghdwsbh>500903733983251</ghdwsbh>
                                  <ghdwmc>重庆富裕汽车销售有限公司</ghdwmc>
                                  <ghdwdzdh>重庆市九龙坡区南华街661号附2-1-1023-68178229</ghdwdzdh>
                                  <ghdwyhzh>建行南方分理处50001043900059666777</ghdwyhzh>
                                  <bmbbbh></bmbbbh>
                                  <hsslbs>0</hsslbs>
                                  <fyxm count='1'>
                                    <group xh='1'>
                                      <fphxz>0</fphxz>
                                      <spmc>商品</spmc>
                                      <spsm></spsm>
                                      <ggxh></ggxh>
                                      <dw></dw>
                                      <spsl>1</spsl>
                                      <dj>1000.00</dj>
                                      <je>1000.00</je>
                                      <sl>0.17</sl>
                                      <se>170.00</se>
                                      <hsbz>0</hsbz>
                                      <spbm>1030299000000000000</spbm>
                                      <zxbm></zxbm>
                                      <yhzcbs>0</yhzcbs>
                                      <slbs>0</slbs>
                                      <zzstsgl></zzstsgl>
                                    </group>
                                  </fyxm>
                                  <zhsl></zhsl>
                                  <hjje>1000.00</hjje>
                                  <hjse>170.00</hjse>
                                  <jshj>1170.00</jshj>
                                  <bz></bz>
                                  <skr>蓝静</skr>
                                  <fhr>卿玉梅</fhr>
                                  <kpr>刘福丽</kpr>
                                  <jmbbh></jmbbh>
                                  <zyspmc>金杯牌厢式运输车</zyspmc>
                                  <spsm></spsm>
                                  <qdbz>0</qdbz>
                                  <ssyf>201605</ssyf>
                                  <kpjh>0000</kpjh>
                                  <tzdbh></tzdbh>
                                  <yfpdm></yfpdm>
                                  <yfphm></yfphm>
                                  <qmcs>" + qmcs + @"</qmcs>
                                </input>
                              </body>
                            </business>";
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票开具' id='FPKJ'>
                              <body yylxdm='1'>
                                <input>
                                  <skpbh>" + skpbh + @"</skpbh>
                                  <skpkl>" + skpkl + @"</skpkl>
                                  <keypwd>" +keypwd+@"</keypwd>
                                  <fplxdm>004</fplxdm>
                                  <kplx>0</kplx>
                                  <tspz>00</tspz>
                                  <xhdwsbh>"+xhdwsbh+@"</xhdwsbh>
                                  <xhdwmc>"+xhdwmc+@"</xhdwmc>
                                  <xhdwdzdh>"+xhdwdzdh+@"</xhdwdzdh>
                                  <xhdwyhzh>"+xhdwyhzh+@"</xhdwyhzh>
                                  <ghdwsbh>500903733983251</ghdwsbh>
                                  <ghdwmc>重庆富裕汽车销售有限公司</ghdwmc>
                                  <ghdwdzdh>重庆市九龙坡区南华街661号附2-1-1023-68178229</ghdwdzdh>
                                  <ghdwyhzh>建行南方分理处50001043900059666777</ghdwyhzh>
                                  <fyxm count='8'>
                                    <group xh='1'>
                                      <fphxz>2</fphxz>
                                      <spmc>金杯牌厢式运输车</spmc>
                                      <spsm></spsm>
                                      <ggxh>SY5020XXY-C4STBW</ggxh>
                                      <dw>辆</dw>
                                      <spsl>15.000000</spsl>
                                      <dj>40100.000000</dj>
                                      <je>601500.00</je>
                                      <sl>0.17</sl>
                                      <se>87397.44</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                    <group xh='2'>
                                      <fphxz>2</fphxz>
                                      <spmc>金杯牌多用途乘用车</spmc>
                                      <spsm></spsm>
                                      <ggxh>SY6420C5SBW</ggxh>
                                      <dw>辆</dw>
                                      <spsl>5.000000</spsl>
                                      <dj>37510.000000</dj>
                                      <je>187550.00</je>
                                      <sl>0.17</sl>
                                      <se>27250.85</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                    <group xh='3'>
                                      <fphxz>2</fphxz>
                                      <spmc>金杯牌多用途乘用车</spmc>
                                      <spsm></spsm>
                                      <ggxh>SY6450C8SBW</ggxh>
                                      <dw>辆</dw>
                                      <spsl>15.000000</spsl>
                                      <dj>47684.000000</dj>
                                      <je>715260.00</je>
                                      <sl>0.17</sl>
                                      <se>103926.67</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                    <group xh='4'>
                                      <fphxz>2</fphxz>
                                      <spmc>金杯牌多用途乘用车</spmc>
                                      <spsm></spsm>
                                      <ggxh>SY6420C5SBW</ggxh>
                                      <dw>辆</dw>
                                      <spsl>15.000000</spsl>
                                      <dj>36310.000000</dj>
                                      <je>544650.00</je>
                                      <sl>0.17</sl>
                                      <se>79137.18</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                    <group xh='5'>
                                      <fphxz>2</fphxz>
                                      <spmc>金杯牌多用途乘用车</spmc>
                                      <spsm></spsm>
                                      <ggxh>SY6450C8SBW</ggxh>
                                      <dw>辆</dw>
                                      <spsl>6.000000</spsl>
                                      <dj>48184.000000</dj>
                                      <je>289104.00</je>
                                      <sl>0.17</sl>
                                      <se>42006.56</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                    <group xh='6'>
                                      <fphxz>2</fphxz>
                                      <spmc>金杯牌厢式运输车</spmc>
                                      <spsm></spsm>
                                      <ggxh>SY5020XXY-C4STBW</ggxh>
                                      <dw>辆</dw>
                                      <spsl>5.000000</spsl>
                                      <dj>37400.000000</dj>
                                      <je>187000.00</je>
                                      <sl>0.17</sl>
                                      <se>27170.94</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                    <group xh='7'>
                                      <fphxz>2</fphxz>
                                      <spmc>金杯牌多用途乘用车</spmc>
                                      <spsm></spsm>
                                      <ggxh>SY6420C5SBW</ggxh>
                                      <dw>辆</dw>
                                      <spsl>1.000000</spsl>
                                      <dj>32930.000000</dj>
                                      <je>32930.00</je>
                                      <sl>0.17</sl>
                                      <se>4784.70</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                    <group xh='8'>
                                      <fphxz>1</fphxz>
                                      <spmc>折扣行</spmc>
                                      <spsm></spsm>
                                      <ggxh></ggxh>
                                      <dw></dw>
                                      <spsl></spsl>
                                      <dj></dj>
                                      <je>-136910.00</je>
                                      <sl>0.17</sl>
                                      <se>-19892.91</se>
                                      <hsbz>1</hsbz>
                                    </group>
                                  </fyxm>
                                  <zhsl></zhsl>
                                  <hjje>2069302.57</hjje>
                                  <hjse>351781.43</hjse>
                                  <jshj>2421084.00</jshj>
                                  <bz></bz>
                                  <skr>蓝静</skr>
                                  <fhr>卿玉梅</fhr>
                                  <kpr>"+kpr+@"</kpr>
                                  <jmbbh></jmbbh>
                                  <zyspmc>金杯牌厢式运输车</zyspmc>
                                  <spsm></spsm>
                                  <qdbz>0</qdbz>
                                  <ssyf>201605</ssyf>
                                  <kpjh>"+kpjh+@"</kpjh>
                                  <tzdbh></tzdbh>
                                  <yfpdm></yfpdm>
                                  <yfphm></yfphm>
                                  <qmcs>"+qmcs+@"</qmcs>
                                </input>
                              </body>
                            </business>";
            this.textBox1.Text = strin.ToString();
        }

        private void btn_FPZF_MouseDown(object sender, MouseEventArgs e)
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票作废' id='FPZF'>
                            <body yylxdm='1'>
                            <input>
                            <nsrsbh>500102010002166</nsrsbh>
                            <skpbh>499000121852</skpbh>
                            <skpkl>88888888</skpkl>
                            <keypwd>111111</keypwd>
                            <fplxdm>004</fplxdm>
                            <zflx>1</zflx>
                            <fpdm>1110098079</fpdm>
                            <fphm>87650005</fphm>
                            <hjje>14086.15</hjje>
                            <zfr>蓝进</zfr>
                            <qmcs>0000004282000000</qmcs>
                            </input>
                            </body>
                            </business>";
            this.textBox1.Text = str.ToString();
        }

        private void button2_MouseDown(object sender, MouseEventArgs e)
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票查询' id='FPCX'>
                            <body yylxdm='1'>
                            <input>
                            <nsrsbh>"+xhdwsbh+@"</nsrsbh>
                            <skpbh>"+skpbh+@"</skpbh>
                            <skpkl>"+skpkl+ @"</skpkl>
                            <keypwd>"+keypwd+ @"</keypwd>
                            <fplxdm>004</fplxdm>
                            <cxfs>0</cxfs>
                            <cxtj>33300005553591000235910002</cxtj>
                            <cxlx>0</cxlx>
                            </input>
                            </body>
                            </business>";
            this.textBox1.Text = str.ToString();
        }

        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                <business comment='发票打印' id='FPDY'>
                <body yylxdm='1'>
                <input>
                <nsrsbh>500102010002255</nsrsbh>
                <skpbh>499000123647</skpbh>
                <skpkl>88888888</skpkl>
                <keypwd>111111</keypwd>
                <fplxdm>004</fplxdm>
                <fpdm>3330000555</fpdm>
                <fphm>39910002</fphm>
                <dylx>0</dylx>
                <dyfs>1</dyfs>
                </input>
                </body>
                </business>";
            this.textBox1.Text = str.ToString();
        }

        private void btn_FPSC_MouseDown(object sender, MouseEventArgs e)
        {
            string str = @"<?xml version='1.0' encoding='gbk'?>
                            <business comment='发票上传' id='FPSC'>
                            <body yylxdm='1'>
                            <input>
                            <nsrsbh>500102010000394</nsrsbh>
                            <skpbh>499000107284</skpbh>
                            <skpkl>88888888</skpkl>
                            <keypwd>111111</keypwd>
                            <svrIp>218.70.65.77</svrIp>
                            <svrPort>444</svrPort>
                            <fplxdm>004</fplxdm>
                            <fpzs>1</fpzs>
                            <czlx></czlx>
                            </input>
                            </body>
                            </business>";
            this.textBox1.Text = str.ToString();
        }
    }
}
